package com.thh.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * @Author thh
 * @Description
 * @Version 1.0
 **/
@Service
public class DispatchService {

    @Autowired
    JdbcTemplate jdbcTemplate;


    /*
     * @Author thh
     * @Description 运单添加
     * @Date 15:29 2020/4/29
     * @Param [orderId]
     * @return void
     **/
    @Transactional(propagation = Propagation.REQUIRED)
    public void dispatch(String orderId) throws Exception {
        String sql = "insert into table_dispatch (dispatch_seq,order_id) values(UUID(),?)";
        // 添加订单记录
        int count = jdbcTemplate.update(sql,orderId);
        if(count != 1){
            throw  new SQLException("订单创建失败，原因【数据操作失败】。");
        }
    }







}
